package com.lzs.adx.web.commmon.utils;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;

public class DateUtil {

    public static LocalDateTime getYesterdayStartingTime() {
        LocalDate yesterday = LocalDate.now().minusDays(2);
        LocalTime midnight = LocalTime.MIDNIGHT;
        return LocalDateTime.of(yesterday, midnight);
    }




    public static LocalDateTime getYesterdayEndingTime() {
        LocalDate yesterday = LocalDate.now().minusDays(2);
        LocalTime lastSecond = LocalTime.of(23, 59, 59);
        return LocalDateTime.of(yesterday, lastSecond);
    }

    public static String getYesterdayStime() {
        LocalDateTime yesterdayStartingTime = getYesterdayStartingTime();
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        return formatter.format(yesterdayStartingTime);
    }

    public static String getYesterdayEtime() {
        LocalDateTime yesterdayEndingTime = getYesterdayEndingTime();
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        return formatter.format(yesterdayEndingTime);
    }

    public static String getCurrentTime() {
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
        return formatter.format(LocalDateTime.now());
    }


    public static void main(String[] args) {
        String yesterdayStime = getYesterdayStime();
        String yesterdayEtime = getYesterdayEtime();
        System.out.println(yesterdayStime);
        System.out.println(yesterdayEtime);
        System.out.println(getCurrentTime());
    }


}
